#include <my_header.h>
/* Usage: ./cp path */
void copy_file(const char *src, const char *dest){

    FILE * src_fp = fopen (src,"r");
    //错误信息处理
    ERROR_CHECK(src_fp,NULL,"foprn src");
   // if(src_fp == NULL){
     //   perror("fopen src");
       // exit(1);
   // }
   FILE *dest_fp = fopen(dest, "w");
   ERROR_CHECK(dest_fp,NULL,"fopen dest");

   //设置用于临时存储数据的中转站
   char buf[1024] = { 0 };
   size_t count;

   //从源文件中读取数据并且写入目标文件
   while((count = fread(buf,1,sizeof(buf),src_fp)) > 0){
       fwrite(buf,1,count,dest_fp);
    }
   //关闭文件流
   fclose(src_fp);
   fclose(dest_fp);

}

int main(int argc,char *argv[])
{
    ARGS_CHECK(argc, 3);
    copy_file(argv[1],argv[2]);
    return 0;
}

